package com.ruoyi.project.mahjong.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.mahjong.domain.SendMoney;
import com.ruoyi.project.mahjong.domain.TWork;
import com.ruoyi.project.mahjong.domain.enu.ShopLogEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mahjong.mapper.ShopLogMapper;
import com.ruoyi.project.mahjong.domain.ShopLog;
import com.ruoyi.project.mahjong.service.IShopLogService;

/**
 * 店铺日志Service业务层处理
 *
 * @author ruoyi
 * @date 2023-12-01
 */
@Service
public class ShopLogServiceImpl implements IShopLogService
{
    @Autowired
    private ShopLogMapper shopLogMapper;

    /**
     * 查询店铺日志
     *
     * @param id 店铺日志ID
     * @return 店铺日志
     */
    @Override
    public ShopLog selectShopLogById(Long id)
    {
        return shopLogMapper.selectShopLogById(id);
    }

    /**
     * 查询店铺日志列表
     *
     * @param shopLog 店铺日志
     * @return 店铺日志
     */
    @Override
    public List<ShopLog> selectShopLogList(ShopLog shopLog)
    {
        return shopLogMapper.selectShopLogList(shopLog);
    }

    /**
     * 新增店铺日志
     *
     * @param shopLog 店铺日志
     * @return 结果
     */
    @Override
    public int insertShopLog(ShopLog shopLog)
    {
        shopLog.setCreateTime(DateUtils.getNowDate());
        return shopLogMapper.insertShopLog(shopLog);
    }

    /**
     * 修改店铺日志
     *
     * @param shopLog 店铺日志
     * @return 结果
     */
    @Override
    public int updateShopLog(ShopLog shopLog)
    {
        shopLog.setUpdateTime(DateUtils.getNowDate());
        return shopLogMapper.updateShopLog(shopLog);
    }

    /**
     * 批量删除店铺日志
     *
     * @param ids 需要删除的店铺日志ID
     * @return 结果
     */
    @Override
    public int deleteShopLogByIds(Long[] ids)
    {
        return shopLogMapper.deleteShopLogByIds(ids);
    }

    /**
     * 删除店铺日志信息
     *
     * @param id 店铺日志ID
     * @return 结果
     */
    @Override
    public int deleteShopLogById(Long id)
    {
        return shopLogMapper.deleteShopLogById(id);
    }

    @Override
    public void saveLogGoWrok(TWork tWork,Long shopId) {
        ShopLog log=new ShopLog();
        log.setTime(tWork.getSbTime());
        log.setType(ShopLogEnum.SB.getValue());
        log.setCreateBy(tWork.getStaffId().toString());
        log.setShopId(shopId);
        log.setMoney(tWork.getInitMoney().toString());
        insertShopLog(log);

    }

    @Override
    public void saveLogDowmWrok(TWork tWork, Long shopId) {
        ShopLog log=new ShopLog();
        log.setTime(tWork.getXbTime());
        log.setType(ShopLogEnum.XB.getValue());
        log.setCreateBy(tWork.getUpdateBy());
        log.setShopId(shopId);
        log.setMoney(tWork.getRemainingMoney().toString());
        insertShopLog(log);
    }

    @Override
    public void saveSendMoney(SendMoney sendMoney) {
        ShopLog log=new ShopLog();
        log.setTime(sendMoney.getSendTime());
        log.setType(ShopLogEnum.QK.getValue());
        log.setCreateBy(sendMoney.getCreateBy());
        log.setShopId(sendMoney.getShopId());
        log.setMoney(sendMoney.getMoney());
        insertShopLog(log);
    }
}
